package com.xbts.screen.controller;

import java.util.List;

import com.xbts.common.core.domain.R;
import com.xbts.common.core.enums.DateTypeEnum;
import com.xbts.common.security.annotation.RequiresPermissions;
import com.xbts.common.core.domain.WeProduceInformationStatistics;
import com.xbts.screen.service.IWeProduceInformationStatisticsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xbts.common.log.annotation.Log;
import com.xbts.common.core.web.controller.BaseController;
import com.xbts.common.core.web.domain.AjaxResult;
import com.xbts.common.log.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import com.xbts.common.core.web.page.TableDataInfo;

/**
 * 产能信息统计Controller
 * 
 * @author xbts
 * @date 2024-01-02
 */
@Api(tags = "产能信息统计管理")
@RestController
@RequestMapping("/screen/produceInformationStatistics")
public class WeProduceInformationStatisticsController extends BaseController {

    @Autowired
    private IWeProduceInformationStatisticsService weProduceInformationStatisticsService;


    /**
     * 查询产能信息统计列表
     */
    @ApiOperation("获取产能信息统计列表")
    @RequiresPermissions("screen:produceInformationStatistics:list")
    @GetMapping("/list")
    public TableDataInfo list(WeProduceInformationStatistics weProduceInformationStatistics) {
        startPage();
        List<WeProduceInformationStatistics> list = weProduceInformationStatisticsService.list(weProduceInformationStatistics.queryWrapper());
        return getDataTable(list);
    }
    /**
     * 获取产能信息统计详细信息
     */
    @ApiOperation("获取产能信息统计详细")
    @ApiImplicitParam(name = "id", value = "产能信息统计ID", required = true, dataType = "String", paramType = "path")
    @RequiresPermissions("screen:produceInformationStatistics:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(weProduceInformationStatisticsService.getById(id));
    }

    /**
     * 新增产能信息统计
     */
    @ApiOperation("新增产能信息统计")
    @RequiresPermissions("screen:produceInformationStatistics:add")
    @Log(title = "产能信息统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WeProduceInformationStatistics weProduceInformationStatistics) {
        return toAjax(weProduceInformationStatisticsService.save(weProduceInformationStatistics));
    }

    /**
     * 修改产能信息统计
     */
    @ApiOperation("更新产能信息统计")
    @RequiresPermissions("screen:produceInformationStatistics:edit")
    @Log(title = "产能信息统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WeProduceInformationStatistics weProduceInformationStatistics) {
        return toAjax(weProduceInformationStatisticsService.updateById(weProduceInformationStatistics));
    }

    /**
     * 删除产能信息统计
     */
    @ApiOperation("删除产能信息统计")
    @ApiImplicitParam(name = "ids", value = "产能信息统计ID集合", required = true, dataType = "String", paramType = "path")
    @RequiresPermissions("screen:produceInformationStatistics:remove")
    @Log(title = "产能信息统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<String> ids) {
        return toAjax(weProduceInformationStatisticsService.removeByIds(ids));
    }

    /**
     * 产能信息统计定时任务
     */
    @GetMapping(value = "/task")
    public AjaxResult task() {
        return toAjax(weProduceInformationStatisticsService.task());
    }

    /**
     * 根据工序获取产能信息
     */
    @ApiImplicitParam(name = "productionProcesses", value = "工序", required = true, dataType = "String", paramType = "path")
    @GetMapping(value = "/byProductionProcesses/{productionProcesses}")
    public AjaxResult byProductionProcesses(@PathVariable String productionProcesses, DateTypeEnum dateType) {
        return success(weProduceInformationStatisticsService.byProductionProcesses(productionProcesses, dateType));
    }

    /**
     * 获取产能信息详情
     */
    @GetMapping(value = "/getDetails")
    public AjaxResult getDetails(DateTypeEnum dateType) {
        return success(weProduceInformationStatisticsService.getDetails(dateType));
    }
}
